home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / modula2 / hk_lib / def_mod / timer.mod < prev    next >
Encoding:
Modula Implementation  |  1994-09-22  |  2.5 KB  |  83 lines

  1. IMPLEMENTATION MODULE  Timer;
  2.  
  3. (*****************************************************************************)
  4. (* Als Stoppuhr wird die Systemvariable _hz_200 benutzt, die alle 5 ms hoch- *)
  5. (* gezaehlt wird, dadurch entsteht kein zusaetzlicher Zeitverlust durch einen*)
  6. (* sonst zu programmierenden Interrupt von Timer A des MFP 68901.            *)
  7. (*___________________________________________________________________________*)
  8. (*  03-Mae-90 , hk                                                           *)
  9. (*****************************************************************************)
  10.  
  11. FROM  SYSTEM  IMPORT  (* PROC *) INLINE;
  12.  
  13. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  14.  
  15. PROCEDURE  Start ((* -- /AUS *) VAR startzeit : LONGCARD );
  16. (*T*)
  17.   BEGIN
  18. (*
  19.     Supexec    EQU  38
  20.     XBIOS      EQU  14
  21.     hz200      EQU  $4BA
  22.  
  23.     startzeit  EQU  12
  24.  
  25.     Start:
  26.       pea     gettime(pc)      ; Adresse der auszufuehrenden Prozedur
  27.       move.w  #Supexec, -(sp)  ; Prozedur im Supervisormodus ausfuehren
  28.       trap    #XBIOS           ;
  29.       bra.s   ende             ; fertig
  30.  
  31.     gettime:
  32.       movea.l startzeit(a6),a0
  33.       move.l  hz200, (a0)      ; bisherige Anzahl der 200Hz IR's als
  34.                                ; Startzeitpunkt
  35.       rts
  36.  
  37.     ende:
  38. *)
  39.    INLINE( 487AH,000AH,3F3CH,0026H,4E4EH,600CH,206EH,000CH,20B9H );
  40.    INLINE( 0000H,04BAH,4E75H );
  41.  
  42.   END  Start;
  43.  
  44. (*---------------------------------------------------------------------------*)
  45.  
  46. PROCEDURE  Stop ((* EIN/ -- *) startzeit : LONGCARD ): LONGCARD;
  47. (*T*)
  48.   BEGIN
  49. (*
  50.     Supexec    EQU  38
  51.     XBIOS      EQU  14
  52.     hz200      EQU  $4BA
  53.  
  54.     starttime  EQU  12
  55.     RETURN     EQU  starttime + 4
  56.  
  57.     Stop:
  58.       pea     calctime(pc)      ; Adresse der auszufuehrenden Prozedur
  59.       move.w  #Supexec, -(sp)   ; Prozedur im Supervisormodus ausfuehren
  60.       trap    #XBIOS            ;
  61.       bra.s   ende              ; fertig
  62.  
  63.     calctime:
  64.       move.l  hz200, d0
  65.       sub.l   startzeit(a6), d0 ; Differenz der 200Hz IR's von jetzt und
  66.                                 ; dem Startzeitpunkt
  67.       move.l  d0, d1            ; Differenz mal 5, damit als Millisekunden
  68.       add.l   d0, d0            ;
  69.       add.l   d0, d0            ;
  70.       add.l   d1, d0            ;
  71.       move.l  d0, RETURN(a6)
  72.       rts
  73.  
  74.     ende:
  75. *)
  76.     INLINE( 487AH,000AH,3F3CH,0026H,4E4EH,6018H,2039H,0000H,04BAH );
  77.     INLINE( 90AEH,000CH,2200H,0D080H,0D080H,0D081H,2D40H,0010H,4E75H );
  78.  
  79.   END Stop;
  80.  
  81.  
  82. END  Timer.
  83.